package StructuralMode.flyweight;

import java.util.Hashtable;

/**
 * 享元工厂
 */
public class FlyweightFactory {
     private static final FlyweightFactory flyweightFactory = new FlyweightFactory();
     private Hashtable<String,AbstractBox> boxMap = new Hashtable<>();

     private FlyweightFactory() {
           boxMap.put("L",new BoxL());
           boxMap.put("I",new BoxI());
           boxMap.put("O",new BoxO());
     }

     public static FlyweightFactory getFlyweightFactory() {
          return flyweightFactory;
     }

     public AbstractBox getBox(String shape){
          return boxMap.get(shape);
     }
}
